#include<bits/stdc++.h>
using namespace std;
int a[100005];
int cnt[100005];
int main(){
    freopen("color.in","w",stdin);
    freopen("color.out","r",stdout);
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        int ans=0;
        for(int i=1;i<=10000;i++){
            cnt[i]=0;
        }
        for(int i=1;i<=n;i++){
            cin>>a[i];
            cnt[a[i]]++;
        }
        for(int i=1;i<=100000;i++){
            if(cnt[i]>1){
                int x=cnt[i]/2;
                ans+=x*i;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}
